package com.bstech.CustomControls;

import com.bstech.assistance.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class OreSelector extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.selector);
		LoadControls();
	}
	
	private void LoadControls()
	{
		ListView list = (ListView)findViewById(R.id.selector_listview);
		list.setEmptyView(findViewById(R.id.selector_emptyView));
		
		ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.array_ore, R.layout.combobox_item_selection );
    	adapter.setDropDownViewResource(R.layout.combobox_item_selection );
    	list.setAdapter(adapter);
		
		list.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
				Bundle b = new Bundle();
				b.putString("selected", (String)arg0.getItemAtPosition(arg2) );
				Intent intent = new Intent();
				intent.putExtras(b);
				setResult(RESULT_OK, intent);
				finish();
			}
		});
	}
}
